#!/bin/sh

echo "Building snack.js"

# build base file
cat src/core.js src/wrap.js src/event.js src/publisher.js src/ajax.js src/element.js > builds/snack.js

# replace %build%
#rev=`git rev-parse head`
#sed "s/%build%/$rev/" builds/snack.js > builds/snack-out.js ; mv builds/snack-out.js builds/snack.js

# compress
uglifyjs builds/snack.js > builds/snack-min.js
gzip -c builds/snack-min.js > builds/snack-min.js.gz

snack=`stat -f %z builds/snack.js`
min=`stat -f %z builds/snack-min.js`
gz=`stat -f %z builds/snack-min.js.gz`

echo "  ==> snack.js                     | $snack bytes"
echo "  ==> snack-min.js                 |  $min bytes"
echo "  ==> gzipped                      |  $gz bytes"

# just wanted to know the size, delete it now
rm builds/snack-min.js.gz





# echo
# echo "Building snack-qwery.js"

# build base file
cat builds/snack.js vendor/qwery/qwery.js src/engines/qwery.js > builds/snack-qwery.js

# compress
uglifyjs builds/snack-qwery.js > builds/snack-qwery-min.js
gzip -c builds/snack-qwery-min.js > builds/snack-min.js.gz

snack=`stat -f %z builds/snack-qwery.js`
min=`stat -f %z builds/snack-qwery-min.js`
gz=`stat -f %z builds/snack-min.js.gz`

# echo "  ==> builds/snack-qwery.js        | $snack bytes"
# echo "  ==> builds/snack-qwery-min.js    | $min bytes"
# echo "  ==> gzipped                      |  $gz bytes"

# just wanted to know the size, delete it now
rm builds/snack-min.js.gz





# echo
# echo "Building snack-slick.js"

# build base file
cat builds/snack.js vendor/slick/Source/Slick.Parser.js vendor/slick/Source/Slick.Finder.js src/engines/slick.js > builds/snack-slick.js

# compress
uglifyjs builds/snack-slick.js > builds/snack-slick-min.js
gzip -c builds/snack-slick-min.js > builds/snack-min.js.gz

snack=`stat -f %z builds/snack-slick.js`
min=`stat -f %z builds/snack-slick-min.js`
gz=`stat -f %z builds/snack-min.js.gz`

# echo "  ==> builds/snack-slick.js        | $snack bytes"
# echo "  ==> builds/snack-slick-min.js    | $min bytes"
# echo "  ==> gzipped                      |  $gz bytes"

# just wanted to know the size, delete it now
rm builds/snack-min.js.gz




# echo
# echo "Building snack-sizzle.js"

# build base file
cat builds/snack.js vendor/sizzle/sizzle.js src/engines/sizzle.js > builds/snack-sizzle.js

# compress
uglifyjs builds/snack-sizzle.js > builds/snack-sizzle-min.js
gzip -c builds/snack-sizzle-min.js > builds/snack-min.js.gz

snack=`stat -f %z builds/snack-sizzle.js`
min=`stat -f %z builds/snack-sizzle-min.js`
gz=`stat -f %z builds/snack-min.js.gz`

# echo "  ==> builds/snack-sizzle.js       | $snack bytes"
# echo "  ==> builds/snack-sizzle-min.js   | $min bytes"
# echo "  ==> gzipped                      |  $gz bytes"

# just wanted to know the size, delete it now
rm builds/snack-min.js.gz

tar czf docs/snack.tar.gz builds